package GameLogic
{
	import BasicEngine.Dispatcher;
	import DataStore.BmpDataPool;
	import fl.controls.TextArea;
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.events.Event;
	public class TraceWin extends Sprite
	{
		public  var TraceInfo:TextArea;
		public var Info:String = "";
		private var bmp:Bitmap;
		private var timer:int;
		private var nums:int = 0;
		public function TraceWin()
		{
			TraceInfo = new TextArea();
			TraceInfo.editable = false;
			TraceInfo.enabled = true;
			TraceInfo.alpha = 1;
			TraceInfo.x = 9;
			TraceInfo.y = 5;
			TraceInfo.width = 282;
			TraceInfo.height = 200;
			addChild(TraceInfo);
			bmp = new Bitmap(BmpDataPool.LuaeditPool[120]);
			addChild(bmp);
			Show(false);
			//Info = "Start";
		}
		
		public function Show(_v:Boolean):void
		{ 
			if (_v)
			{
			   this.addEventListener(Event.EXIT_FRAME, Update);
			   this.visible = true;
			}
			else
			{
			   this.removeEventListener(Event.EXIT_FRAME, Update);
			   this.visible = false;
			   TraceInfo.text = "";
			   nums = 0;
			}
		}
		
		public function SetInfo(_st:String):void
		{
			Info = _st;
		}
		
		private function Update(e:Event):void
		{
			if (Game.Pause)
			   return;
			if (Dispatcher.Clock.SystemTime - timer > 400)
			{
				timer = Dispatcher.Clock.SystemTime;
				if (Info.length > 0)
				{
				    TraceInfo.text = Info +"\n"+ TraceInfo.text;
				    //Info = nums.toString();
					
					nums++;
				    if (nums > 150)
				    {
				    	nums = 0;
				    	TraceInfo.text = "";
				    }
				}
			}
		}
	}
}